#include<bits/stdc++.h>
using namespace std;
namespace IO{
    char buff[1<<21],*p1=buff,*p2=buff;
    char getch(){
        return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
    }
    template<typename T>
    void read(T &x){
        char ch=getch();int fl=1;x=0;
        while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
        while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
        x*=fl;
    }
    template<typename T,typename ...Args>
    void read(T &x,Args& ...args){
        read(x);read(args...);
    }
    char obuf[1<<21],*p3=obuf;
    void putch(char ch){
        if(p3-obuf<(1<<21))*p3++=ch;
        else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
    }
    void pc(const char *s){
    	while(*s)putch(*s),s++;
    }
    char ch[100];
    template<typename T>
    void write(T x){
        if(!x)return putch('0');
        if(x<0)putch('-'),x*=-1;
        int top=0;
        while(x)ch[++top]=x%10+48,x/=10;
        while(top)putch(ch[top]),top--;
    }
    template<typename T,typename ...Args>
    void write(T x,Args ...args){
        write(x),putch(' '),write(args...);
    }
    void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
const int N=2e5+5,Inf=1e9;
int n;
int a[N],b[N],ans[N];
bool check1(){
	for(int i=1;i<=n;i++)if(b[i]!=1)return 0;
	return 1;
}
void SUB1(){
	int minn=a[1];
	for(int i=1;i<=n;i++)minn=min(minn,a[i]);
	for(int i=1;i<=n;i++)write(minn-1),putch('\n');
	flush();
}
bool check2(){
	for(int i=1;i<=n;i++)if(b[i]!=Inf)return 0;
	return 1;
}
int pre[N],suf[N];
int st[N],tot;
void SUB2(){
	st[tot=1]=0;
	for(int i=1;i<=n;i++){
		while(tot&&a[st[tot]]>=a[i])tot--;
		pre[i]=st[tot];
		st[++tot]=i;
	}
	st[tot=1]=n+1;
	for(int i=n;i>=1;i--){
		while(tot&&a[st[tot]]>=a[i])tot--;
		suf[i]=st[tot];
		st[++tot]=i;
	}
	for(int i=1;i<=n;i++)ans[suf[i]-pre[i]-1]=max(ans[suf[i]-pre[i]-1],a[i]);
	for(int i=n;i>=1;i--)ans[i]=max(ans[i],ans[i+1]);
	for(int i=1;i<=n;i++)write(Inf-ans[i]),putch('\n');
	flush();
}
signed main(){
	freopen("min.in","r",stdin);
	freopen("min.out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	for(int i=1;i<=n;i++)read(b[i]);
	if(check1())return SUB1(),0;
	if(check2())return SUB2(),0;
	memset(ans,0x3f,sizeof ans);
	for(int l=1;l<=n;l++){
		int minn1=a[l],minn2=b[l];
		for(int r=l;r<=n;r++){
			minn1=min(minn1,a[r]),
			minn2=min(minn2,b[r]);
			ans[r-l+1]=min(ans[r-l+1],abs(minn1-minn2));
		}
	}
	for(int i=1;i<=n;i++)write(ans[i]),putch('\n');
	flush();
	return 0;
}

